package org.gdstash.description;

public class TagInfo {
    public static final String TAG_UNI_RACE_DAMAGE = "TXT_UNI_RACE_DAMAGE";
    private String tag;
    private int infoType;
    private int prio;
    private ValueType valueType;
    private FlatCategory flatCat;
    private SignCategory signCat;
    private RandCategory randCat;
    private boolean baseStat;

    public TagInfo(final String tag, final int prio) {
        this(tag, prio, ValueType.INT, FlatCategory.ABSOLUTE, SignCategory.OPTIONAL, false, RandCategory.JITTER);
    }

    public TagInfo(final String tag, final int prio, final boolean baseStat) {
        this(tag, prio, ValueType.INT, FlatCategory.ABSOLUTE, SignCategory.OPTIONAL, baseStat, RandCategory.JITTER);
    }

    public TagInfo(final String tag, final int prio, final ValueType valueType, final RandCategory randCat, final boolean baseStat) {
        this(tag, prio, valueType, FlatCategory.ABSOLUTE, SignCategory.OPTIONAL, baseStat, randCat);
    }

    public TagInfo(final String tag, final int prio, final ValueType valueType, final RandCategory randCat) {
        this(tag, prio, valueType, FlatCategory.ABSOLUTE, SignCategory.OPTIONAL, false, randCat);
    }

    public TagInfo(final String tag, final int prio, final FlatCategory valueCat) {
        this(tag, prio, ValueType.INT, valueCat, SignCategory.OPTIONAL, false, RandCategory.JITTER);
    }

    public TagInfo(final String tag, final int prio, final FlatCategory flatCat, final boolean baseStat) {
        this(tag, prio, ValueType.INT, flatCat, SignCategory.OPTIONAL, baseStat, RandCategory.JITTER);
    }

    public TagInfo(final String tag, final int prio, final FlatCategory valueCat, final RandCategory randCat) {
        this(tag, prio, ValueType.INT, valueCat, SignCategory.OPTIONAL, false, randCat);
    }

    public TagInfo(final String tag, final int prio, final FlatCategory flatCat, final boolean baseStat, final RandCategory randCat) {
        this(tag, prio, ValueType.INT, flatCat, SignCategory.OPTIONAL, false, randCat);
    }

    public TagInfo(final String tag, final int prio, final RandCategory randCat) {
        this(tag, prio, ValueType.INT, FlatCategory.ABSOLUTE, SignCategory.OPTIONAL, false, randCat);
    }

    public TagInfo(final String tag, final int prio, final ValueType valueType, final FlatCategory flatCat, final SignCategory signCat, final boolean baseStat, final RandCategory randCat) {
        this.tag = tag;
        this.prio = prio;
        this.valueType = valueType;
        this.flatCat = flatCat;
        this.signCat = signCat;
        this.baseStat = baseStat;
        this.randCat = randCat;
        this.setFlags();
    }

    private void setFlags() {
        if (this.tag.startsWith("DEF_")) {
            this.infoType = 1;
            this.flatCat = FlatCategory.PERCENTAGE;
            if (this.tag.equals("DEF_PROTECTION")) {
                this.flatCat = FlatCategory.ABSOLUTE;
            }
        }
        if (this.tag.startsWith("OFF_")) {
            this.infoType = 2;
        }
        if (this.tag.startsWith("RET_")) {
            this.infoType = 3;
        }
        if (this.tag.startsWith("STAT_")) {
            this.infoType = 4;
        }
    }

    public String getTag() {
        return this.tag;
    }

    public int getPriority() {
        return this.prio;
    }

    public boolean isScaling() {
        final boolean scale = this.randCat == RandCategory.SCALE || this.randCat == RandCategory.SCALE_JITTER;
        return scale;
    }

    public boolean isJittering() {
        final boolean jitter = this.randCat == RandCategory.JITTER || this.randCat == RandCategory.SCALE_JITTER;
        return jitter;
    }

    public boolean isBaseStat() {
        return this.baseStat;
    }

    public boolean isMinAsPerc() {
        return this.flatCat == FlatCategory.PERCENTAGE;
    }

    public boolean isMinAsDuration() {
        return this.flatCat == FlatCategory.DURATION;
    }

    public boolean isFloatValue() {
        return this.valueType == ValueType.FLOAT;
    }

    public boolean isSignMandatory() {
        return this.signCat == SignCategory.MANDATORY;
    }

    public int getInfoType() {
        return this.infoType;
    }

    public enum ValueType {
        INT,
        FLOAT;
    }

    public enum FlatCategory {
        ABSOLUTE,
        PERCENTAGE,
        DURATION;
    }

    public enum SignCategory {
        OPTIONAL,
        MANDATORY;
    }

    public enum RandCategory {
        FIXED,
        SCALE,
        JITTER,
        SCALE_JITTER;
    }
}
